<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<script  type="text/javascript">
	var cur_cert_id;
	
	<!--  获取客户端证书信息-->
	function getSignCertInfo(){
		cur_cert_id = LoginForm.UserList.value;//证书ID
		
		ESeaL_GetUserCert(cur_cert_id, function(ret){document.getElementById("sign_cert").value = ret.retVal;});//签名证书
		ESeaL_GetStampPic(cur_cert_id, function(ret){document.getElementById("seal_img").value = ret.retVal;});//印章
	}
	
    <!--  客户端签名-->
	function clientSign(){
		var digestData = document.getElementById("digest_data").value;
		var userPwd = document.getElementById("UserPwd").value;
		ESeaL_ClientSignByHash(digestData, cur_cert_id, userPwd, function(ret){
			alert(ret.retVal);
			document.getElementById("sign_data").value = ret.retVal;
		});
	}
	
	<!--  客户端登录-->
	function clientLogin() {
		var strCertID =  LoginForm.UserList.value;
		var strPin = LoginForm.UserPwd.value;
		//alert(strCertID);
		VerifyUserPIN(strCertID, strPin, function(strRes) {
			if (!strRes.retVal) {
				alert("校验PIN码失败");
				return;
			}
			alert("校验PIN码成功!\r\n");
		});
	}

</script>

<title>客户端签章</title>
</head>
<body style="text-align:center;">
<form method="post" ID="LoginForm" name="LoginForm">
		<div> <span style="font-size:25px">客户端签章集成DEMO</span></div><br>
		<div> 
			<table border="1">
				<tr>
					<td colspan=2><button type="button" onclick="getSignCertInfo()">获取客户端签章参数</button> </td>
				</tr>
				<tr>
					<td>选择证书</td>
					<td><select id="UserList" name="UserList"></select></td>
				</tr>
				<tr>
					<td>签章证书</td>
					<td><textarea id="sign_cert" rows="4" cols="50"></textarea></td>
				</tr>
				<tr>
					<td>印章</td>
					<td><textarea id="seal_img" rows="4" cols="50"></textarea></td>
				</tr>
			</table>
			<br>			
			<table border="1">
				<tr>
					<td colspan=2>
					 <div id="pwdinfo">手工输入证书密码</div> <input type="password" name="pwd1" id="UserPwd" size="16" maxlength="16">
					<button id="login_id" type="button" onclick="clientLogin()">客户端login</button>
					<button type="button" onclick="clientSign()">执行客户端签名</button>
					</td>
				</tr>
				<tr>
					<td>摘要数据</td>
					<td><textarea id="digest_data" rows="4" cols="50">{"digestMessages":[{"signUniqueId":"a42b5f67419e495f91e3abfa8f9d79b1_2130706433","fileUniqueId":"hello_pdf","hashData":"nkSAMH8Obu4zYD1Ak9KyEtTnjLw="}]}</textarea></td>
				</tr>
				<tr>
					<td>签名数据</td>
					<td><textarea id="sign_data" rows="4" cols="50"></textarea></td>
				</tr>
			</table>
		</div>
</form>	

<SCRIPT type="text/javascript" src="/static/ProxySeal/pdfsign.js"></SCRIPT>
<SCRIPT type="text/javascript" src="/static/ProxySeal/WS_pdfsign.js"></SCRIPT>
<SCRIPT LANGUAGE=JAVASCRIPT>
	SetUserCertList("LoginForm.UserList", CERT_TYPE_HARD);

	var SGD_SHA1 = 2;
	var SGD_SHA256 = 4;
	ESeaL_SetHashAlg(SGD_SHA1);//默认为sha256
	
	//passwd needn't exist in IE browser. 
	if($checkBrowserISIE()) {
		//document.getElementById("pwdinfo").style.visibility="hidden"; 
		// document.getElementById("UserPwd").style.visibility="hidden"; 
		// document.getElementById("login_id").style.visibility="hidden"; 			
	}
</SCRIPT>	
</body>
</html>

